
/*
#include<bits/stdc++.h>
using namespace std;

const int N = 10;
int n;
int g[N][N];
void dfs(int u)
{
	if (n == u)
	{
	    for (int i = 0; i < n; i ++)
	       for (int j = 0; j < n; j ++)
	           cout << g[i][j];
	    
	}
}
int main()
{
	cin >> n;
	dfs(0);
    return 0;
}
*/

#include<bits/stdc++.h>
using namespace std;

const int N = 10;
char g[N][N];
int n;
bool col[N], dg[N], udg[N];
void dfs(int x)
{
    
		if(x == n)
		{
			for (int i = 0; i < n; i ++)
	    	cout << g[i]<<endl;
		    cout << endl;
	    	return ;
		}
	for (int i = 0; i < n; i ++)
	{
		if (!col[i] && !dg[i + x] && !udg[n - x + i])
		{
			g[x][i] = 'Q';
			col[i] = dg[i + x] = udg[n - x + i] = true;
			dfs(x + 1);
			col[i] = dg[i + x] = udg[n - x + i] = false;
			g[x][i] = '.';
		}
	}
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i ++)
		for(int j = 0; j < n; j ++)
		    g[i][j] = '.';
    dfs(0);	
	return 0;
}
				
/*
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	cout << 1 <<endl;
	return 0;
}
*/








